home *** CD-ROM | disk | FTP | other *** search
/ Compendium Deluxe 2 / LSD and 17bit Compendium Deluxe - Volume II.iso / a / prog / amigae / mac2e_v40.lha / Mac2E / Sources / OptiMUI2E.e < prev   
Encoding:
Text File  |  1994-08-12  |  4.7 KB  |  220 lines

  1. OPT OSVERSION=37
  2.  
  3.  
  4. ->*****
  5. ->** Exception handling
  6. ->*****
  7. RAISE    "MEM"    IF    New()        =    NIL    ,
  8.         "ARGS"    IF    ReadArgs()    =    NIL    ,
  9.         "OPEN"    IF    Open()        =    NIL    ,
  10.         "IN"    IF    Read()        =    -1    ,
  11.         "OUT"    IF    Read()        =    -1
  12.  
  13.  
  14. /*******************
  15. ** Main procedure **
  16. *******************/
  17. PROC main() HANDLE
  18.  
  19.     DEF rdargs , args : PTR TO LONG
  20.     DEF file = NIL , file_adr , file_length , file_end
  21.     DEF version
  22.  
  23.     PrintF( '            \c1;33;40\cOptiMUI2E\c0;31;40\c v1.2\n' , $9B , $6D , $9B , $6D )
  24.     PutStr( 'Copyright © 1993, 1994, Lionel Vintenat\n' )
  25.     PrintF( '\c1;32;40\c---------------------------------------\c0;31;40\c\n' , $9B , $6D , $9B , $6D )
  26.     version := '$VER: OptiMUI2E 1.2 (12.08.94)'
  27.  
  28.     args := [ NIL , NIL ]
  29.     rdargs := ( rdargs := NIL ) BUT ReadArgs( 'FROM/A,TO/A' , args , NIL )
  30.  
  31.     file := Open( args[ 0 ] , OLDFILE )
  32.     file_length := FileLength( args[ 0 ] )
  33.     file_adr := NewR( file_length )
  34.     file_end := file_adr + file_length
  35.     Read( file , file_adr , file_length )
  36.     Close( file )
  37.  
  38.     file := Open( args[ 1 ] , NEWFILE )
  39.  
  40.     process( file , file_adr , file_end )
  41.  
  42.     Close( file )
  43.     FreeArgs( rdargs )
  44.  
  45. EXCEPT
  46.  
  47.     SELECT exception
  48.  
  49.         CASE "ARGS"
  50.  
  51.             PrintFault(IoErr(),NIL)
  52.  
  53.         CASE "MEM"
  54.  
  55.             PutStr('Out of memory !\n')
  56.  
  57.         CASE "OPEN"
  58.  
  59.             PrintFault(IoErr(),NIL)
  60.  
  61.         CASE "IN"
  62.  
  63.             PrintFault(IoErr(),NIL)
  64.  
  65.         CASE "OUT"
  66.  
  67.             PrintFault(IoErr(),NIL)
  68.  
  69.     ENDSELECT
  70.  
  71.     IF rdargs THEN    FreeArgs(rdargs)
  72.     IF file THEN Close( file )
  73.  
  74.     CleanUp(100)
  75.  
  76. ENDPROC
  77.  
  78.  
  79. /*********************************************************************
  80. ** Performs the "', [TAG_IGNORE, 0" string replacements in the file **
  81. *********************************************************************/
  82. PROC process( file , file_adr , file_end )
  83.  
  84.     DEF part_end , part_start
  85.  
  86.     part_start := file_adr
  87.  
  88.     MOVE.L    file_adr , A0
  89.     MOVE.L    file_end , A1
  90.     while0:
  91.         CMPA.L    A1 , A0                -> string_ptr = file_end ?
  92.         BEQ.W    fin_while1
  93.         MOVE.B    (A0)+ , D0
  94.     while1:
  95.         CMP.B    #"'" , D0             -> string_ptr[] = "'" ?
  96.         BNE.B    while0
  97.  
  98.         CMPA.L    A1 , A0                -> string_ptr = file_end ?
  99.         BEQ.W    fin_while1
  100.         MOVE.B    (A0)+ , D0
  101.         CMP.B    #"," , D0             -> string_ptr[] = "," ?
  102.         BNE.B    while1
  103.  
  104.         CMPA.L    A1 , A0                -> string_ptr = file_end ?
  105.         BEQ.W    fin_while1
  106.         MOVE.B    (A0)+ , D0
  107.         CMP.B    #" " , D0             -> string_ptr[] = " " ?
  108.         BNE.B    while1
  109.  
  110.         CMPA.L    A1 , A0                -> string_ptr = file_end ?
  111.         BEQ.W    fin_while1
  112.         MOVE.B    (A0)+ , D0
  113.         CMP.B    #"[" , D0             -> string_ptr[] = "[" ?
  114.         BNE.B    while1
  115.  
  116.         CMPA.L    A1 , A0                -> string_ptr = file_end ?
  117.         BEQ.W    fin_while1
  118.         MOVE.B    (A0)+ , D0
  119.         CMP.B    #"T" , D0             -> string_ptr[] = "T" ?
  120.         BNE.B    while1
  121.  
  122.         CMPA.L    A1 , A0                -> string_ptr = file_end ?
  123.         BEQ.W    fin_while1
  124.         MOVE.B    (A0)+ , D0
  125.         CMP.B    #"A" , D0             -> string_ptr[] = "A" ?
  126.         BNE.B    while1
  127.  
  128.         CMPA.L    A1 , A0                -> string_ptr = file_end ?
  129.         BEQ.W    fin_while1
  130.         MOVE.B    (A0)+ , D0
  131.         CMP.B    #"G" , D0             -> string_ptr[] = "G" ?
  132.         BNE.B    while1
  133.  
  134.         CMPA.L    A1 , A0                -> string_ptr = file_end ?
  135.         BEQ.W    fin_while1
  136.         MOVE.B    (A0)+ , D0
  137.         CMP.B    #"_" , D0             -> string_ptr[] = "_" ?
  138.         BNE.B    while1
  139.  
  140.         CMPA.L    A1 , A0                -> string_ptr = file_end ?
  141.         BEQ.W    fin_while1
  142.         MOVE.B    (A0)+ , D0
  143.         CMP.B    #"I" , D0             -> string_ptr[] = "I" ?
  144.         BNE.B    while1
  145.  
  146.         CMPA.L    A1 , A0                -> string_ptr = file_end ?
  147.         BEQ.W    fin_while1
  148.         MOVE.B    (A0)+ , D0
  149.         CMP.B    #"G" , D0             -> string_ptr[] = "G" ?
  150.         BNE.W    while1
  151.  
  152.         CMPA.L    A1 , A0                -> string_ptr = file_end ?
  153.         BEQ.W    fin_while1
  154.         MOVE.B    (A0)+ , D0
  155.         CMP.B    #"N" , D0             -> string_ptr[] = "N" ?
  156.         BNE.W    while1
  157.  
  158.         CMPA.L    A1 , A0                -> string_ptr = file_end ?
  159.         BEQ.W    fin_while1
  160.         MOVE.B    (A0)+ , D0
  161.         CMP.B    #"O" , D0             -> string_ptr[] = "O" ?
  162.         BNE.W    while1
  163.  
  164.         CMPA.L    A1 , A0                -> string_ptr = file_end ?
  165.         BEQ.W    fin_while1
  166.         MOVE.B    (A0)+ , D0
  167.         CMP.B    #"R" , D0             -> string_ptr[] = "R" ?
  168.         BNE.W    while1
  169.  
  170.         CMPA.L    A1 , A0                -> string_ptr = file_end ?
  171.         BEQ.W    fin_while1
  172.         MOVE.B    (A0)+ , D0
  173.         CMP.B    #"E" , D0             -> string_ptr[] = "E" ?
  174.         BNE.W    while1
  175.  
  176.         CMPA.L    A1 , A0                -> string_ptr = file_end ?
  177.         BEQ.W    fin_while1
  178.         MOVE.B    (A0)+ , D0
  179.         CMP.B    #"," , D0             -> string_ptr[] = "," ?
  180.         BNE.W    while1
  181.  
  182.         CMPA.L    A1 , A0                -> string_ptr = file_end ?
  183.         BEQ.W    fin_while1
  184.         MOVE.B    (A0)+ , D0
  185.         CMP.B    #" " , D0             -> string_ptr[] = " " ?
  186.         BNE.W    while1
  187.  
  188.         CMPA.L    A1 , A0                -> string_ptr = file_end ?
  189.         BEQ.W    fin_while1
  190.         MOVE.B    (A0)+ , D0
  191.         CMP.B    #"0" , D0             -> string_ptr[] = "0" ?
  192.         BNE.W    while1
  193.  
  194.         MOVE.L    A0 , part_end
  195.         Write( file , part_start , part_end - part_start -13 )
  196.         MOVE.L    part_end , A0
  197.         MOVE.L    file_end , A1
  198.  
  199.         while2:
  200.             CMPA.L    A1 , A0
  201.             BEQ.B    fin_while1
  202.             MOVE.B    (A0)+ , D0
  203.             CMP.B    #"," , D0
  204.             BEQ.B    while2
  205.             CMP.B    #" " , D0
  206.             BEQ.B    while2
  207.             CMP.B    #9 , D0
  208.             BEQ.B    while2
  209.             CMP.B    #10 , D0
  210.             BEQ.B    while2
  211.             fin_while2:
  212.         SUBQ.L    #1 , A0
  213.         MOVE.L    A0 , part_start
  214.         BRA.W    while1
  215.     fin_while1:
  216.     MOVE.L    A0 , part_end
  217.     Write( file , part_start , part_end - part_start )
  218.  
  219. ENDPROC
  220.